<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link type="text/css" rel="stylesheet" href="/TP/Public/css/style.css" />
    <!--[if IE 6]>
    <script src="/TP/Public/js/iepng.js" type="text/javascript"></script>
        <script type="text/javascript">
           EvPNG.fix('div, ul, img, li, input, a'); 
        </script>
    <![endif]-->
    
    <script type="text/javascript" src="/TP/Public/js/jquery-2.1.3.min.js"></script> 
    <script type="text/javascript" src="/TP/Public/js/menu.js"></script>    
                
	<script type="text/javascript" src="/TP/Public/js/n_nav.js"></script>   
    
    <script type="text/javascript" src="/TP/Public/js/num.js">
    	var jq = jQuery.noConflict();
    </script>     
    
    <script type="text/javascript" src="/TP/Public/js/shade.js"></script>
    
<title>数码商城</title>
</head>
<body>  
<!--Begin Header Begin-->
 <div class="soubg">
	<div class="sou">
        <span class="fr">
        	<span class="fl">
                <?php if(empty($username)): ?>你好，请<a href="<?php echo U('Home/Login/index');?>">登录</a>&nbsp; <a href="<?php echo U('Home/User/Regist');?>" style="color:#ff4e00;">免费注册　</a>
                <?php else: ?>
                    你好&nbsp;<?php echo ($username); ?>&nbsp;<a href="<?php echo U('Home/index/tuichu');?>">退出</a><?php endif; ?> 
            <a href="<?php echo U('Home/member/index');?>">&nbsp;|个人中心</a>&nbsp;|
            </span>
        	　<span class="ss">
            	<div class="ss_list">
                	<a href="#">收藏夹</a>
                    <div class="ss_list_bg">
                    	<div class="s_city_t"></div>
                        <div class="ss_list_c">
                        	<ul>
                            	<li><a href="<?php echo U('Home/member/Member_Collect');?>">我的收藏夹</a></li>
                            </ul>
                        </div>
                    </div>     
                </div>
                <div class="ss_list">
                	<a href="#">客户服务</a>
                    <div class="ss_list_bg">
                    	<div class="s_city_t"></div>
                        <div class="ss_list_c">
                        	<ul>
                            	<li><a href="#">客户服务</a></li>
                                <li><a href="#">客户服务</a></li>
                                <li><a href="#">客户服务</a></li>
                            </ul>
                        </div>
                    </div>    
                </div>
                <div class="ss_list">
                	<a href="#">网站导航</a>
                    <div class="ss_list_bg">
                    	<div class="s_city_t"></div>
                        <div class="ss_list_c">
                        	<ul>
                            	<li><a href="#">网站导航</a></li>
                                <li><a href="#">网站导航</a></li>
                            </ul>
                        </div>
                    </div>    
                </div>
            </span>
            <span class="fl">|&nbsp;关注我们：</span>
            <span class="s_sh"><a href="#" class="sh1">新浪</a><a href="#" class="sh2">微信</a></span>
            <span class="fr">|&nbsp;<a href="#">手机版&nbsp;<img src="/TP/Public/images/s_tel.png" align="absmiddle" /></a></span>
        </span>
    </div>
</div>
<div class="top">
    <div class="logo"><img src="/TP/Public/images/logo.jpg" width="200" height="60" /></div>
     <div class="search">
      <form method="get" action="<?php echo U('home/list/seach');?>">
          <input type="text" name="seach" class="s_ipt" />
            <input type="submit" value="搜索" class="s_btn" />
        </form>                      
    </div>
    <!-- onmouseover="mouserover('user')"  [ <span>3</span> ] -->
    <div class="i_car" >
    	<div class="car_t" >购物车</div>
        <div class="car_bg">
       	
        <?php  if($_SESSION['user']['id']){ $buycar = M('buycar'); $map['uid'] = ['eq',session('user')['id']]; $blist = $buycar->where($map)->select(); echo ' <ul class="cars">'; foreach($blist as $blist){ echo '
                          <li>
                          <div class="img"><a href="#"><img src="/TP/Uploads/comm/'.$blist['goodspic'].'" width="58" height="58" /></a></div>
                            <div class="name"><a href="#">'.$blist['goodsname'].'</a></div>
                            <div class="price"><font color="#ff4e00">'.$blist['price'].'￥</font> X'.$blist['number'].'</div>
                          </li>
        
                      '; } echo '  </ul>'; }else{ echo '<div class="un_login">还未登录<a href="/TP/Home/Login/index.html" style="color:#ff4e00;">马上登录</a> 查看购物车！</div>'; } ?>

        </div>
    </div>
</div>
<script>
    // function mouserover(user){
    //     jq.get("<?php echo U('Home/Header/header');?>",{'user':user},function(data){
    //       // alert(data);
    //     });
    // }

</script>
<!--End Header End--> 
<!--Begin Menu Begin-->
<div class="menu_bg">
	<div class="menu">
    	<!--Begin 商品分类详情 Begin-->    
    	<div class="nav">
        	<div class="nav_t">全部商品分类</div>
            <div class="leftNav none">
                <ul>      
                     <?php if(is_array($t_list)): $i = 0; $__LIST__ = $t_list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$t_list): $mod = ($i % 2 );++$i;?><li>
                        <div class="fj">
                            <span class="n_img"><span></span><img src="/TP/Public/images/nav1.png" /></span>
                            <span class="fl"><?php echo ($t_list["name"]); ?></span>
                        </div> 
                        <?php if(!empty($t_list['lower'])): ?><div class="zj">
                            <div class="zj_l">
                             <?php if(is_array($t_list[lower])): $i = 0; $__LIST__ = $t_list[lower];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$w_list): $mod = ($i % 2 );++$i;?><div class="zj_l_c">
                                    <h2><a href="<?php echo U('Home/List/index',['id'=>$w_list['id']]);?>"><?php echo ($w_list['name']); ?></a></h2>
                                    <?php if(!empty($w_list['lower'])): if(is_array($w_list['lower'])): $i = 0; $__LIST__ = $w_list['lower'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$e_list): $mod = ($i % 2 );++$i;?><a href="<?php echo U('Home/List/index',['id'=>$e_list['id']]);?>"><?php echo ($e_list['name']); ?></a>|<?php endforeach; endif; else: echo "" ;endif; endif; ?>
                                </div><?php endforeach; endif; else: echo "" ;endif; ?>
                            </div>
                        
                        </div><?php endif; ?>
                    </li><?php endforeach; endif; else: echo "" ;endif; ?>
                </ul>            
            </div>
        </div>  
        <!--End 商品分类详情 End-->                                                     
    	<ul class="menu_r">    
		<!--导航栏-->
	    			<li><a href="/TP/index.php">首页</a></li>
            <?php if(is_array($bar)): foreach($bar as $key=>$bar): ?><li><a href="<?php echo U('Home/list/index',['id'=>$bar['id']]);?>"><?php echo ($bar["name"]); ?></a></li>
     <!--        <li><a href="Fresh.html">生鲜</a></li>
            <li><a href="HomeDecoration.html">家居</a></li>
            <li><a href="SuitDress.html">女装</a></li>
            <li><a href="MakeUp.html">美妆</a></li>
            <li><a href="Digital.html">数码</a></li>
            <li><a href="GroupBuying.html">团购</a></li> --><?php endforeach; endif; ?>	
        </ul>
    </div>
</div>
<!--End Menu End--> 
<div class="i_bg">  
    <div class="content mar_20">
    	<img src="/TP/Public/images/img1.jpg" />        
    </div>
    
    <!--Begin 第一步：查看购物车 Begin -->
    <div class="content mar_20">
    	<table border="0" class="car_tab" style="width:1200px; margin-bottom:50px;" cellspacing="0" cellpadding="0">
          <tr>
            <td class="car_th" width="490">商品名称</td>
            <td class="car_th" width="140">属性</td>
            <td class="car_th" width="150">购买数量</td>
            <td class="car_th" width="130">小计</td>
            <td class="car_th" width="140">返还积分</td>
            <td class="car_th" width="150">操作</td>
          </tr>
          <?php if(is_array($list)): foreach($list as $key=>$val): ?><tr id = "buycar_tr<?php echo ($val["id"]); ?>" class="clear_bc">
            <td>
                <label class="r_rad"><input type="checkbox" id="status_<?php echo ($val["id"]); ?>" <?php echo ($val['status']==1?checked:""); ?> onclick="status(<?php echo ($val["id"]); ?>)" name="clear" /></label>
            	<div class="c_s_img"><img src="/TP/Uploads/comm/<?php echo ($val['goodspic']); ?>" width="73" height="73" /></div>
                <?php echo ($val['goodsname']); ?> 
            </td>
            <td align="center">颜色：<?php echo ($val['color']); ?><br>内存：<?php echo ($val['size']); ?></td>
            <td align="center">
            	<div class="c_num">
                    <input type="button" value="" id="buycar_jian<?php echo ($val["id"]); ?>" onclick="jianupdate(<?php echo ($val["id"]); ?>,<?php echo ($val["price"]); ?>)" class="car_btn_1" />
                	<input type="text" id="bc_number<?php echo ($val["id"]); ?>" readonly value="<?php echo ($val["number"]); ?>" name="" class="car_ipt" />  
                    <input type="button" value="" onclick="jiaupdate(<?php echo ($val["id"]); ?>,<?php echo ($val["price"]); ?>)" class="car_btn_2" />
                </div>
                
                <!-- onclick="jianUpdate1(jq(this)); -->
            </td>
            <td align="center" id="bc_total<?php echo ($val["id"]); ?>" style="color:#ff4e00;">￥<?php echo ($val["total"]); ?></td>
            <td align="center" id = "bc_integral<?php echo ($val["id"]); ?>" ><?php echo ($val["integral"]); ?></td>
           <!-- href="<?php echo U('Home/Buycar/del_bc');?>?id=<?php echo ($val['id']); ?>"  -->
            <td align="center"><a onclick="buycar_del(<?php echo ($val["id"]); ?>)">删除</a>&nbsp; &nbsp;<a href="#" onclick="add_keep(<?php echo ($val["gid"]); ?>)">加入收藏</a></td>
            <!-- href="<?php echo U('Home/Buycar/del_bc');?>?id=<?php echo ($val['id']); ?>" -->
          </tr><?php endforeach; endif; ?>
            
          <tr height="70">
          	<td colspan="6" style="font-family:'Microsoft YaHei'; border-bottom:0;">
            <!-- href="<?php echo U('Home/Buycar/clear_bc');?>?uid=<?php echo ($val["uid"]); ?>" -->
            	<label class="r_rad"></label><label class="r_txt"><a onclick="clear_buycar(<?php echo ($val["uid"]); ?>)">清空购物车</a></label>
                <span class="fr">商品总价：￥<b id="buycar_total" style="font-size:22px; color:#ff4e00;"><?php echo ($total); ?></b></span>
            </td>
          </tr>

          <tr valign="top" height="150">
          	<td colspan="6" align="right">
            	<a href="<?php echo U('Home/Index/index');?>"><img src="/TP/Public/images/buy1.gif" /></a>&nbsp; &nbsp; <a href="<?php echo U('Home/Orders/index');?>"><img src="/TP/Public/images/buy2.gif" /></a>
            </td>
          </tr>
        </table>
        <!-- 分页 -->
          <!-- <div align="right"><?php echo ($show); ?></div> -->
    </div>
	<!--End 第一步：查看购物车 End--> 
    <!--Begin Footer Begin -->
	  <div class="b_btm_bg b_btm_c">
        <div class="b_btm">
            <table border="0" style="width:210px; height:62px; float:left; margin-left:75px; margin-top:30px;" cellspacing="0" cellpadding="0">
              <tr>
                <td width="72"><img src="/TP/Public/images/b1.png" width="62" height="62" /></td>
                <td><h2>正品保障</h2>正品行货  放心购买</td>
              </tr>
            </table>
			<table border="0" style="width:210px; height:62px; float:left; margin-left:75px; margin-top:30px;" cellspacing="0" cellpadding="0">
              <tr>
                <td width="72"><img src="/TP/Public/images/b2.png" width="62" height="62" /></td>
                <td><h2>满38包邮</h2>满38包邮 免运费</td>
              </tr>
            </table>
            <table border="0" style="width:210px; height:62px; float:left; margin-left:75px; margin-top:30px;" cellspacing="0" cellpadding="0">
              <tr>
                <td width="72"><img src="/TP/Public/images/b3.png" width="62" height="62" /></td>
                <td><h2>天天低价</h2>天天低价 畅选无忧</td>
              </tr>
            </table>
            <table border="0" style="width:210px; height:62px; float:left; margin-left:75px; margin-top:30px;" cellspacing="0" cellpadding="0">
              <tr>
                <td width="72"><img src="/TP/Public/images/b4.png" width="62" height="62" /></td>
                <td><h2>准时送达</h2>收货时间由你做主</td>
              </tr>
            </table>
        </div>
    </div>
    <div class="b_nav">
    	<dl>                                                                                            
        	<dt><a href="#">新手上路</a></dt>
            <dd><a href="#">售后流程</a></dd>
            <dd><a href="#">购物流程</a></dd>
            <dd><a href="#">订购方式</a></dd>
            <dd><a href="#">隐私声明</a></dd>
            <dd><a href="#">推荐分享说明</a></dd>
        </dl>
        <dl>
        	<dt><a href="#">配送与支付</a></dt>
            <dd><a href="#">货到付款区域</a></dd>
            <dd><a href="#">配送支付查询</a></dd>
            <dd><a href="#">支付方式说明</a></dd>
        </dl>
        <dl>
        	<dt><a href="#">会员中心</a></dt>
            <dd><a href="#">资金管理</a></dd>
            <dd><a href="#">我的收藏</a></dd>
            <dd><a href="#">我的订单</a></dd>
        </dl>
        <dl>
        	<dt><a href="#">服务保证</a></dt>
            <dd><a href="#">退换货原则</a></dd>
            <dd><a href="#">售后服务保证</a></dd>
            <dd><a href="#">产品质量保证</a></dd>
        </dl>
        <dl>
        	<dt><a href="#">友情链接</a></dt>
            <?php if(is_array($link)): foreach($link as $key=>$link): ?><dd><a href="<?php echo ($link["linkaddress"]); ?>"><?php echo ($link["linkname"]); ?></a></dd><?php endforeach; endif; ?>
        </dl>
        <div class="b_tel_bg">
        	<a href="#" class="b_sh1">新浪微博</a>            
        	<a href="#" class="b_sh2">腾讯微博</a>
            <p>
            服务热线：<br />
            <span>400-123-4567</span>
            </p>
        </div>
        <div class="b_er">
            <div class="b_er_c"><img src="/TP/Public/images/er.gif" width="118" height="118" /></div>
            <img src="/TP/Public/images/ss.png" />
        </div>
    </div>    
    <div class="btmbg">
		<div class="btm">
        	备案/许可证编号：蜀ICP备12009302号-1-www.dingguagua.com   Copyright © 2015-2018 尤洪商城网 All Rights Reserved. 复制必究 , Technical Support: Dgg Group <br />
            <img src="/TP/Public/images/b_1.gif" width="98" height="33" /><img src="/TP/Public/images/b_2.gif" width="98" height="33" /><img src="/TP/Public/images/b_3.gif" width="98" height="33" /><img src="/TP/Public/images/b_4.gif" width="98" height="33" /><img src="/TP/Public/images/b_5.gif" width="98" height="33" /><img src="/TP/Public/images/b_6.gif" width="98" height="33" />
        </div>    	
    </div>
    <!--End Footer End -->    
</div>

</body>
<script>
    var jq = jQuery.noConflict();
    //设置商品总价
    // var total += parseInt(jq('.car_ipt').val());
    // alert(total);
    //减
    function jianupdate(id,price){
        // alert(id);
        // alert(number);
        //设置获取number值id
        var a = '#bc_number'+id;
        //设置total id
        var t = '#bc_total'+id;
        // alert(a);
        var i = '#bc_integral'+id;
        var integral = jq(i).html();
        var number = jq(a).val();
        jq.get("<?php echo U('Home/Buycar/up_bc');?>",{
            'id':id,
            'number':number,
            'price':price,
            'integral':integral
        },function(data){
            // alert(data);
            if(data > 0 ){
                //设置trid
                var p = '#buycar_tr'+id;
                if(number - 1 == 0){
                    jq(p).remove();
                     var total = jq('#buycar_total').html();
                    // alert(total);
                    total = parseInt(total);
                    // alert(total);
                    total = total - price;
                    // alert(total);
                    jq('#buycar_total').html(total)
                }else{
                    jq(a).val(number-1);
                    jq(t).html((number-1)*price);
                    var total = jq('#buycar_total').html();
                    // alert(total);
                    total = parseInt(total);
                    // alert(total);
                    total = total - price;
                    // alert(total);
                    // 拼接id
                    var integral = "#bc_integral"+id;
                    var inte = jq(integral).html();
                    inte = inte - 50;
                    jq(integral).html(inte);
                    jq('#buycar_total').html(total);
                    var status = "#status_"+id;
                    jq(status).attr('checked',"true");
                    
                }
                
            }
        });

    }
    //加
    function jiaupdate(id,price)
    {
        var a = '#bc_number'+id;
        //设置total id
        var t = '#bc_total'+id;
        // alert(a);
         var i = '#bc_integral'+id;
        var integral = jq(i).html();
        var number = jq(a).val();
        jq.get("<?php echo U('Home/Buycar/up_bct');?>",{
            'id':id,
            'number':number,
            'price':price,
            'integral':integral
        },function(data){
            // alert(data);
            if(data > 0 ){
                number = parseInt(number);
                var s = number+1;
                jq(a).val(s);
                jq(t).html(s*price);
                 var total = jq('#buycar_total').html();
                    // alert(total);
                    total = parseInt(total);
                    // alert(total);
                    total = total + price;
                    // alert(total);
                    jq('#buycar_total').html(total);
                    var integral = "#bc_integral"+id;
                    var inte = jq(integral).html();
                    inte = parseInt(inte);
                    inte = inte + 50;
                    jq(integral).html(inte);
                     var status = "#status_"+id;
                    jq(status).attr('checked',"true");

            }
        });

    }
    //删除操作
     function buycar_del(id){
        if(confirm('是否删除') == true){
            jq.get("<?php echo U('Home/Buycar/del_bc');?>",{'id':id},function(data){
                if(data == '删除成功'){
                    var buycar = "#buycar_tr"+id;
                    jq(buycar).remove();
                    jq.get("<?php echo U('Home/Buycar/sec_total');?>",function(data){
                        jq("#buycar_total").html(data);
                    });
                }else{
                    alert(data);
                }
            });
        }
    }
    //清空购物车操作
    function clear_buycar(uid){
        if(confirm('是否清空购物车') == true){
            jq.get("<?php echo U('Home/Buycar/clear_bc');?>",{'uid':uid},function(data){
                if(data == '清空购物车成功'){
                    jq(".clear_bc").remove();
                    jq("#buycar_total").html(0);
                }else{
                    alert(data);
                }
            });
        }
    }
    // 修改状态
    function status(id){
        jq.get("<?php echo U('Home/buycar/by_status');?>",{'id':id},function(data){
            var total = jq('#buycar_total').html();
            // alert(total);
            total = parseInt(total);
            data = parseInt(data);
            // alert(data);
            // console.log(typeof data);
            if(data < 0){
                var status = "#status_"+id;
                jq(status).removeAttr('checked');
            }
            total = total + data;
            jq('#buycar_total').html(total);
        });
    }
    //加入收藏
    function add_keep(id){
        var url = "<?php echo U('Home/Keep/add_Keep');?>";
        jq.get(url,{'id':id},function(data){
            alert(data);
        });
    }
</script>

<!--[if IE 6]>
<script src="/TP/Public///letskillie6.googlecode.com/svn/trunk/2/zh_CN.js"></script>
<![endif]-->
</html>